/**
    * 虚拟登录  
    * @/views/budget/iseeVirtualLogin
    * 2020-9-7
    * zengfx
 */
<template>
  <div class="virtualLogin_container" v-loading="showAllLoading"></div>
</template>

<script>
import { getRequestParams } from "@/common/js/fastInquiryFn2";
import { setCookie, delCookie } from "@/common/js/cookie";
import { setSessionStorage } from "@/common/js/storage";
import { $loginAPI } from "@/api";
export default {
  data() {
    return {
      showAllLoading: true,
      param: null,
    };
  },
  methods: {
    handle_virtualLogin() {
      let that = this,
        param = {
        userMobile: this.param.userMobile,
      };
      debugger
      $loginAPI.isseLogin(
        { userMobile: that.param.userMobile },
        (res) => {
          if (res.code == 0) {
            // 保存token
            setCookie("token", res.content.token);
            setSessionStorage("accountInfo", res.content.userInfo);
            window.sessionStorage.setItem("SysUserCode", res.content.username);
            window.sessionStorage.setItem("userName", res.content.userName);
            this.showAllLoading = false;
            // incomeAnalysis_total dashboard
            res.content.userInfo.roleId == 5 ? this.$router.push({ path: "/dashboard/index" }) : this.$router.push({ path: "/budget/dashboard" });
          } else {
            this.showAllLoading = false;
            this.$message.error(res.message);
            this.$router.push({ path: "/login" });
          }
        },
        (err) => {
          this.showAllLoading = false;
          this.$router.push({ path: "/login" });
        }
      );
    },
  },
  created() {
    this.param = getRequestParams();
    // this.param = window.zjhc;
    console.log(this.param.userMobile);
    this.$nextTick(() => {
      this.handle_virtualLogin();
    });
  },
};
</script>

<style lang="scss" scoped>
.virtualLogin_container {
  width: 100%;
  height: 100%;
}
</style>